package com.chinatechstar.mq.rabbit;

import java.util.Date;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * RabbitMQ生产者
 * 
 * @版权所有 上海至界信息科技有限公司 
 */
@Component
@RestController
public class RabbitSender {

	@Autowired
	private AmqpTemplate rabbitTemplate;
	private static int count = 1;

	/**
	 * 发送
	 */
	@RequestMapping("/send")
	public void send() {
		String context = count++ + ">>>hello " + new Date();
		System.out.println("Sender : " + context);
		this.rabbitTemplate.convertAndSend("hello", context);
	}

}
